import 'amfe-flexible'
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import Cube from 'cube-ui'
import App from './App'
import router from './router'
import "./assets/theme.less"
import {get,post} from "./utils/request";
import store from './store';
Vue.use(Cube)

Vue.config.productionTip = false
router.beforeEach((to, from, next) => {
    if (to.path != '/login' && to.path != '/register'&& to.path != '/find' && to.path != "/profile") {
        let access_token = store.state.token;
        if (access_token == null) {
            next('/login')
        } else {
            next();
        }
    } else {
        next();
    }
});

Vue.prototype.$get = get;
Vue.prototype.$post = post;
/* eslint-disable no-new */
new Vue({
    el: '#app',
    router,
    store,
    template: '<App/>',
    components: {App}
})
